<!DOCTYPE html>
<html  lang="en">
    <head>
        <title>Document</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
        <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">   
        <script src="https://unpkg.com/swiper/swiper-bundle.min.js"> </script>
        <style>
            .swiper-container{
                width: 100%;
                height: 200px;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <div class="swiper-slide" v-for="data in datalist">
                        {{ data }}
                    </div>
                </div>

                <div class="swiper-pagination"></div>
            </div>
        </div>

        <script>
            let vm = new Vue
            ({
                el: '#app',
                data: {
                    datalist: [],
                },
                mounted() {
                    setTimeout( () => {
                        this.datalist = ["111","222","333"]     // 状态改完， 异步更新dom
                        this.$nextTick(()=>{                    // $nextTick() 推迟执行时间
                            new Swiper ('.swiper-container',
                            {
                                autoplay: {
                                    delay: 2500,
                                    disableOnInteraction: false,
                                },
                                pagination: {
                                    el: '.swiper-pagination',
                                }
                            })
                        })
                    },2000)
                },
            })
        </script>
    </body>
</html>